home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / GMS / Source / E / Screens / Scroll&Sprite.e < prev    next >
Encoding:
Text File  |  1997-05-10  |  2.8 KB  |  92 lines

  1. /* Horizontal Scroll 640
  2. ** ---------------------
  3. ** This opens an extra wide screen of 640x256 pixels, and hardware scrolls
  4. ** left and right.  This is *totally* inadequate for platformers, shoot'em-ups
  5. ** etc because the picture size takes up huge amounts of memory.  However for
  6. ** games like Skidmarks, Lemmings, Monkey Island, etc, such large screens can
  7. ** be a necessity.
  8. */
  9.  
  10. MODULE 'games','games/games','exec/memory'
  11.  
  12. PROC main()
  13.    DEF screen:PTR TO gamescreen, palette:PTR TO INT, direction=1:LONG,
  14.        sparkie:PTR TO sprite, zbxy:LONG, timer:LONG, loadpic:PTR TO picture,
  15.        sparkmem:LONG
  16.  
  17. palette := [
  18.   $000000,$400000,$500010,$500010,$600010,$700010,$700010,$800010,
  19.   $900010,$A00010,$B00020,$403020,$C0C000,$F00000,$201010,$808000,
  20.   $10C020,$005000,$B000B0,$600060,$F02000,$901000,$B0B0B0,$F0F0F0,
  21.   $00B0F0,$006080,$506080,$90B0F0,$F0F000,$E0E000,$B0A000,$504000
  22. ]:LONG;
  23.  
  24.    IF gmsbase := OpenLibrary('GMS:GPI/Master.GPI',0)
  25.     SetUserPrefs(0)
  26.     IF (screen := AddScreen([TAGS_GAMESCREEN,0,
  27.         GSA_PALETTE,palette,
  28.         GSA_SCRWIDTH,320,
  29.         GSA_SCRHEIGHT,256,
  30.         GSA_PICWIDTH,640,
  31.         GSA_AMTCOLOURS,32,
  32.         GSA_PLANES,4,
  33.         GSA_SCRATTRIB,HSCROLL OR SPRITES OR NOSCRBDR,
  34.         GSA_SCRMODE,LORES,
  35.         GSA_SCRTYPE,ILBM,
  36.         TAGEND]))
  37.  
  38.      IF (loadpic := LoadPic([TAGS_PICTURE,0,
  39.         PCA_DATA,screen.memptr1,
  40.         PCA_WIDTH,640,
  41.         PCA_HEIGHT,256,
  42.         PCA_PLANES,4,
  43.         PCA_FILE,'GMS:demos/data/PIC.Pic640x256',
  44.         TAGEND]))
  45.  
  46.       IF (sparkmem := SmartLoad('GMS:demos/data/RAW.Sparkie',0,MEMF_CHIP))
  47.  
  48.        IF (sparkie := InitSprite(screen,[TAGS_SPRITE,0,
  49.           SPA_DATA,sparkmem,
  50.           SPA_XCOORD,150,
  51.           SPA_YCOORD,150,
  52.           SPA_WIDTH,16,
  53.           SPA_HEIGHT,21,
  54.           SPA_AMTCOLOURS,16,
  55.           SPA_COLSTART,16,
  56.           SPA_PLANES,2,
  57.           SPA_SCRMODE,LORES,
  58.           SPA_ATTRIB,XLONG,
  59.           TAGEND]))
  60.  
  61.         ShowScreen(screen)
  62.         UpdateSprite(screen,sparkie)
  63.         InitJoyPorts()
  64.  
  65.         REPEAT
  66.           zbxy := ReadMouse(JPORT1)
  67.           IF (timer++ AND $1)
  68.              IF (sparkie.frame = 5) THEN sparkie.frame := 0 ELSE sparkie.frame := sparkie.frame+1
  69.           ENDIF
  70.           sparkie.xpos := sparkie.xpos+getZBXYx(zbxy)
  71.           sparkie.ypos := sparkie.ypos+getZBXYy(zbxy)
  72.           IF (screen.picxoffset = 320) THEN direction := -2
  73.           IF (screen.picxoffset = 0) THEN direction := 2
  74.           screen.picxoffset := screen.picxoffset+direction
  75.           MovePicture(screen)
  76.           WaitVBL()
  77.           UpdateSprite(screen,sparkie)
  78.         UNTIL !(zbxy AND MB_LMB)
  79.  
  80.        FrSprite(sparkie)
  81.        ENDIF
  82.       FreeMemBlock(sparkmem)
  83.       ENDIF
  84.      FreePic(loadpic)
  85.      ENDIF
  86.      DeleteScreen(screen)        
  87.     ENDIF
  88.    CloseGMS()
  89.    ENDIF
  90. ENDPROC
  91.  
  92.